<?php
/**
 * Created by JetBrains PhpStorm.
 * User: adilet
 * Date: 18.01.13
 * Time: 13:24
 * To change this template use File | Settings | File Templates.
 */


class Application_Form_Auth extends Zend_Form
{
  public function init()
  {
    $this->setName('auth_form')
      ->setMethod('post');

    $email = new Zend_Form_Element_Text('email');
    $email->setAttrib('placeholder', 'email')
      ->addValidator(new Zend_Validate_Db_RecordExists(array(
        'table' => 'users',
        'field' => 'email'
      )
    ))
      ->addValidator(new Zend_Validate_EmailAddress())
      ->setRequired(true);
    $this->addElement($email);

    $password = new Zend_Form_Element_Password('password');
    $password->setAttrib('placeholder', 'Пароль')
      ->setRequired(true)
      ->addValidator('StringLength', false, array('min' => 6))
      ->addFilter(new Zend_Filter_StringTrim())
      ->addValidator(new Zend_Validate_NotEmpty());
    $this->addElement($password);

    $submit = new Zend_Form_Element_Submit('submit');
    $submit->setLabel('Зайти');
    $this->addElement($submit);

  }

}

